//
//  ViewFactoryXmlParser.m
//  Architect
//
//  Created by 张伯林 on 2018/1/30.
//  Copyright © 2018年 张伯林. All rights reserved.
//

#import "ViewFactoryXmlParser.h"
@interface ViewFactoryXmlParser ()<NSXMLParserDelegate>
@property(nonatomic)NSMutableDictionary *dict;
@end
@implementation ViewFactoryXmlParser
- (instancetype)init
{
    self = [super init];
    if (self) {
        _dict = [NSMutableDictionary dictionary];
    }
    return self;
}
-(NSMutableDictionary *)parser{
    //绑定代理
    NSString *path = [[NSBundle mainBundle] pathForResource:@"ViewFasctory.config.xml" ofType:@""];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSXMLParser *xmlParser = [[NSXMLParser alloc]initWithContentsOfURL:url];
    xmlParser.delegate = self;
    [xmlParser parse];
    return _dict;
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(nullable NSString *)namespaceURI qualifiedName:(nullable NSString *)qName attributes:(NSDictionary<NSString *, NSString *> *)attributeDict{
    if ([elementName isEqualToString:@"bean"]) {
        NSString *chose = [attributeDict objectForKey:@"chose"];
        NSString *className = [attributeDict objectForKey:@"class"];
        [_dict setObject:className forKey:chose];
    }
}
@end
